package com.hectopascal.goalance.config;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.io.File;

@Configuration
public class FileUploadConfig {
    @Value("${file.upload-dir.photos}")
    private String uploadDirPhoto;

    @Value("${file.upload-dir.documents}")
    private String uploadDirDocument;

    @PostConstruct
    public void createUploadDir(){
        File file1 = new File(uploadDirPhoto);
        if (!file1.exists()) {
            file1.mkdirs();
        }
        File file2 = new File(uploadDirDocument);
        if (!file2.exists()) {
            file2.mkdirs();
        }
    }
}
